home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
jpi
/
music.bas
< prev
next >
Wrap
BASIC Source File
|
1998-01-07
|
2KB
|
65 lines
Attribute VB_Name = "Music"
Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Long
Public Const MaxMusicFiles = 100
Public MusicOn As Boolean
Const NOMUSICFILE = ""
Private Type musfiles
Filename As String
TrackTitle As String
End Type
Private Type Mus
MusicFiles(MaxMusicFiles) As musfiles
MaxMusicFiles As Integer
CurrentFile As String
End Type
Public MusicData As Mus
Private Const MMCONTROLMODE_STOPPED = 525
Public Sub InitializeMusic()
Call LoadMusicData
End Sub
Public Sub LoadMusicData()
Call FileFunctions.OpenGameFile(File_MusicDefinitions, 1)
Do
Line Input #1, a$
If a$ = FILETAG_ENDFILE Then Exit Do
If a$ = "[MUSICDEF]" Then
musicfilenum = musicfilenum + 1
Line Input #1, a$
propvalue$ = MiscFunctions.GetPropertyValue(a$)
MusicData.MusicFiles(musicfilenum).TrackTitle = propvalue$
Line Input #1, a$
propvalue$ = MiscFunctions.GetPropertyValue(a$)
MusicData.MusicFiles(musicfilenum).Filename = Directory_Music & propvalue$
End If
Loop
Close #1
MusicData.MaxMusicFiles = musicfilenum
End Sub
Public Sub PlayMusicFile(Filename$)
nothin = mciExecute("Play " & App.Path & "\" & Filename$)
Music.MusicData.CurrentFile = Filename$
End Sub
Public Sub StopMusic()
If MusicData.CurrentFile <> NOMUSICFILE Then nothin = mciExecute("Stop " & App.Path & "\" & Music.MusicData.CurrentFile)
MusicData.CurrentFile = NOMUSICFILE
End Sub
Public Sub KeepMusicPlaying()
If MusicData.CurrentFile <> NOMUSICFILE Then nothin = mciExecute("Play " & App.Path & "\" & MusicData.CurrentFile)
End Sub
Public Sub PlayTrackByIndex(TrackNum)
If Music.MusicOn = True Then Call PlayMusicFile(MusicData.MusicFiles(TrackNum).Filename)
End Sub
Public Sub PlayTrackByName(TrackName$)
If Music.MusicOn = True Then
For I = 1 To MusicData.MaxMusicFiles
If MusicData.MusicFiles(I).TrackTitle = TrackName$ Then
Call PlayMusicFile(MusicData.MusicFiles(I).Filename)
Exit For
End If
Next I
End If
End Sub
Public Sub CloseMusicDevice()
If MusicData.CurrentFile <> NOMUSICFILE Then nothin = mciExecute("Stop " & Music.MusicData.CurrentFile)
End Sub